package mud

import org.springframework.transaction.annotation.Transactional

import com.unknown.world.Tile

@Transactional(readOnly=true)
class TileService {
	
	public Tile findById(def id){
		return Tile.findById(id)
	}
	public List<Tile> findAll(){
		return Tile.list()
	}
	
	public def findByType(def type, int offset, int count){
		return Tile.findAllByType(type, [offset:offset, max:count, sort:"name", order:"desc"])
	}

    public Tile findByEntityId(def id){
        return Tile.findAllByEntityId(id)?.get(0);
    }
	
	@Transactional
	public Tile save(Tile tile){
		tile.save()
	}
	
	public void delete(Tile tile){
		tile.delete()
	}
	
}
